home *** CD-ROM | disk | FTP | other *** search
- Path: news.duke.edu!usenet
- From: kev@acpub.duke.edu (Kevin Daniels)
- Newsgroups: comp.lang.c
- Subject: help with program
- Date: 11 Apr 1996 22:50:22 -0400
- Organization: Duke University, Durham, NC, USA
- Message-ID: <4kkgde$t2m@news.duke.edu>
- NNTP-Posting-Host: teer10.acpub.duke.edu
-
-
- Can anyone tell me why the following slice of code might be giving the
- unwanted behavior shown below?
-
-
- void g_find_player1_human_move(void)
- {
- int curr_row;
- int curr_col;
- int dest_row;
- int dest_col;
- int ok = 0;
- int val;
- int lcv;
-
- while (!ok) {
-
- printf("\n\nmove from row -> ");
- scanf("%d",&curr_row);
- printf("\n\nmove from col -> ");
- scanf("%d",&curr_col);
- printf("\n\nmove to row -> ");
- scanf("%d",&dest_row);
- printf("\n\nmove to col -> ");
- scanf("%d",&dest_col);
-
- for(lcv = 1; lcv <=40; lcv ++) {
- if((RED_ALIVE.p[lcv].row_pos == curr_row) && (RED_ALIVE.p[lcv].col_pos == curr_col) && (RED_ALIVE.p[lcv].placed_on_board == 1)) {
- ok = g_is_legal_move(RED_ALIVE.p[lcv].row_pos,RED_ALIVE.p[lcv].col_pos,RED_ALIVE.p[lcv].row_pos,RED_ALIVE.p[lcv].col_pos,P1_TURN);
- if (ok) {
- g_make_move(RED_ALIVE.p[lcv].row_pos,RED_ALIVE.p[lcv].col_pos,RED_ALIVE.p[lcv].row_pos,RED_ALIVE.p[lcv].col_pos,P1_TURN);
- }
- }
- }
- }
- }
-
-
- THE UNWANTED BEHAVIOR --
-
- It keeps printing out the lines
-
- move from row ->
-
- move from col ->
-
- move to row ->
-
- move to row ->
-
- without asking the user for his input. I am woring on a UNIX system on
- a university account, if that helps.
-
- If anyone can help, please e-mail me at kev@acpub.duke.edu
-
- thank you
-